package com.learn.springboot.scheduled;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author wangxing
 * @version 2020/8/3 11:48 Administrator
 */
@Component
public class TimeTask {
    Logger logger = LoggerFactory.getLogger(TimeTask.class);
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    /**
     * 配置定时计划任务
     */
    @Scheduled(fixedDelay = 3000)
    public void systemDate() {
//        logger.info("当前时间::::" + formatter.format(LocalDate.now()));
        logger.info("当前时间::::" + formatter.format(LocalDateTime.now()));
    }
}
